<?php
namespace Admin\Controller;
use IDCU\Controller;
use Org\Util\Rbac;
use Think\Auth;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of AdminController
 *
 * @author John
 */
class AdminController extends Controller{
    function _initialize(){
        if (C('USER_AUTH_ON') && !in_array(MODULE_NAME, explode(',', C('NOT_AUTH_MODULE'))) && !in_array(ACTION_NAME, explode(',', C('NOT_AUTH_ACTION')))) {
            if(!Rbac::AccessDecision()){
                //检查认证识别号
                if(!session(C('USER_AUTH_KEY'))){
                    redirect(PHP_FILE . C('USER_AUTH_GATEWAY'));
                }
                $this->error(L('_VALID_ACCESS_'),U("Index/welcome"));
            }
        }
        $server = I('server.');
        $ru = preg_match('/checkLogin/',$server['REQUEST_URI']);
       if($ru){
           session('ru',$ru);
       }
        define('OSS_BUCKET', C("OSS_BUCKET"));
        define('OSS_DOMAIN', C("OSS_DOMAIN"));
        define('OSS_ACCESS_ID', C("OSS_ACCESS_ID"));
        define('OSS_ACCESS_KEY', C("OSS_ACCESS_KEY"));
    }

    public function zhAjaxReturn($code = 0000, $message = null, $info = null){
        $data['code'] = $code;
        $data['message'] = $message === null ? $code : $message;
        $data['data'] = $info;

        $this->ajaxReturn($data);
    }
}